/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package hibernatemodelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Z510
 */
@Entity
@Table(name = "contacto")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contacto.findAll", query = "SELECT c FROM Contacto c"),
    @NamedQuery(name = "Contacto.findById", query = "SELECT c FROM Contacto c WHERE c.id = :id"),
    @NamedQuery(name = "Contacto.findByNombre", query = "SELECT c FROM Contacto c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Contacto.findByTelefono", query = "SELECT c FROM Contacto c WHERE c.telefono = :telefono"),
    @NamedQuery(name = "Contacto.findByEmail", query = "SELECT c FROM Contacto c WHERE c.email = :email"),
    @NamedQuery(name = "Contacto.findByContrasenya", query = "SELECT c FROM Contacto c WHERE c.contrasenya = :contrasenya")})
public class Contacto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Column(name = "telefono")
    private String telefono;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @Column(name = "contrasenya")
    private String contrasenya;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcreador")
    private Collection<Nota> notaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idamigo2")
    private Collection<Seramigo> seramigoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idamigo1")
    private Collection<Seramigo> seramigoCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcreador")
    private Collection<Evento> eventoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idinvitado")
    private Collection<Invitar> invitarCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idanfitrion")
    private Collection<Invitar> invitarCollection1;

    public Contacto() {
    }

    public Contacto(Integer id) {
        this.id = id;
    }

    public Contacto(Integer id, String nombre, String email, String contrasenya) {
        this.id = id;
        this.nombre = nombre;
        this.email = email;
        this.contrasenya = contrasenya;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getContrasenya() {
        return contrasenya;
    }

    public void setContrasenya(String contrasenya) {
        this.contrasenya = contrasenya;
    }

    @XmlTransient
    public Collection<Nota> getNotaCollection() {
        return notaCollection;
    }

    public void setNotaCollection(Collection<Nota> notaCollection) {
        this.notaCollection = notaCollection;
    }

    @XmlTransient
    public Collection<Seramigo> getSeramigoCollection() {
        return seramigoCollection;
    }

    public void setSeramigoCollection(Collection<Seramigo> seramigoCollection) {
        this.seramigoCollection = seramigoCollection;
    }

    @XmlTransient
    public Collection<Seramigo> getSeramigoCollection1() {
        return seramigoCollection1;
    }

    public void setSeramigoCollection1(Collection<Seramigo> seramigoCollection1) {
        this.seramigoCollection1 = seramigoCollection1;
    }

    @XmlTransient
    public Collection<Evento> getEventoCollection() {
        return eventoCollection;
    }

    public void setEventoCollection(Collection<Evento> eventoCollection) {
        this.eventoCollection = eventoCollection;
    }

    @XmlTransient
    public Collection<Invitar> getInvitarCollection() {
        return invitarCollection;
    }

    public void setInvitarCollection(Collection<Invitar> invitarCollection) {
        this.invitarCollection = invitarCollection;
    }

    @XmlTransient
    public Collection<Invitar> getInvitarCollection1() {
        return invitarCollection1;
    }

    public void setInvitarCollection1(Collection<Invitar> invitarCollection1) {
        this.invitarCollection1 = invitarCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contacto)) {
            return false;
        }
        Contacto other = (Contacto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nombre + " - Email: " + email;
    }
    
}
